package com.bingxue.edu.common.enums;


import com.bingxue.edu.framework.enums.Dict;
import com.bingxue.edu.framework.enums.DictEnum;
import com.fasterxml.jackson.annotation.JsonValue;
import com.mybatisflex.annotation.EnumValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 学期
 */
@Getter
@RequiredArgsConstructor
@Dict("学期")
public enum TermEnum implements DictEnum<String> {

    SPRING("SPRING", "春季", "Q1", 2),
    SUMMER("SUMMER", "暑假", "Q2", 3),
    AUTUMN("AUTUMN", "秋季", "Q3", 4),
    WINTER("WINTER", "寒假", "Q4", 1);

    @JsonValue
    @EnumValue
    private final String value;
    private final String label;
    private final String code;
    private final Integer index;

    public static TermEnum getByIndex(Integer index) {
        for (TermEnum item : TermEnum.values()) {
            if (item.getIndex().equals(index)) {
                return item;
            }
        }
        return null;
    }

}
